package com.tiger.security.sample1;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.*;

public class Security1TestServlet extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, java.io.IOException {
        response.setContentType("text/html; charset=\"EUC-JP\"");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head>");
        out.println("<title>SecurityTestServlet</title>");
        out.println("</head>");
        out.println("<body>");
        
        try {
            InitialContext ctx = new InitialContext();
            Object obj = ctx.lookup("java:comp/env/ejb/Security1TestBean");
            Security1TestHome securityTestHome =
                (Security1TestHome)PortableRemoteObject.narrow(obj, Security1TestHome.class);
            Security1Test securityTest =
                securityTestHome.create();
            
            out.println("<p>" + securityTest.method1() + "</p>");
        }
        catch(java.lang.Exception e) {
            out.println("<p>例外" + e.getMessage() + "がスローされました。</p>");
        }
        
        out.println("</body>");
        out.println("</html>");
        out.close();
    }
}
